import pandas as pd

bigtag=pd.read_csv('csv/bigtag.csv')
tags=pd.read_csv('csv/tags.csv',encoding='gbk')

def marge(bigtag,tags):
    id=[]
    name=[]
    preid=[]

    for i in range(len(bigtag)):
        item=bigtag.loc[i]
        id.append(item[0])
        name.append(item[1])
        preid.append(item[2])

    for i in range(len(bigtag)):
        bigitem=bigtag.loc[i]
        for j in range(len(tags)):
            item=tags.loc[j]
            if item[1]==bigitem[1]:
                id.append(100+j)
                name.append(item[0])
                preid.append(bigitem[0])


    df=pd.DataFrame({'tag_id':id,'tag_name':name,'tag_preid':preid})
    return df

if __name__ == '__main__':
    marge(bigtag,tags).to_csv('csv/tag.csv')